#ifndef ORDER_H
#define ORDER_H

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <json/json.h>

using namespace std;

typedef enum{
    Pending=1,
    Shipping,
    Finish,
}STATUSx;

class Order {
private:
    string orderNumber;
    string buyerInfo;
    string productInfo;
    string orderStatus;

public:
    Order(string buyer, string product, string status);

    string getOrderNumber() const;
    string getBuyerInfo() const;
    string getProductInfo() const;
    string getOrderStatus() const;
    void setOrderStatus(string status);
    void setBuyerInfo(string buyer);
    void setProductInfo(string product);
    void displayOrder() const;
    Json::Value toJson() const;
    void fromJson(const Json::Value& jsonData);
    static string CreateOrderNumber();
};

class OrderManager {
private:
    vector<Order> orders;
    string filename;

public:
    OrderManager(string file);

    void addOrder(const Order& order);
    void cancelOrder(const string& orderNumber);
    void modifyOrderStatus(const string& orderNumber, const string& status);
    void modifyOrderBuyer(const string& orderNumber, const string& buyer);
    void modifyOrderProduct(const string& orderNumber, const string& product);
    void displayOrders() const;
    void saveOrders() const;
    bool findOrdersByNum(const string& orderNumber) const;//订单查找
    bool findOrdersByBuyer(const string& orderBuyer) const;//订单查找
private:
    void loadOrders();
};

#endif  // ORDER_H